package com.masterclient.app.modules.order;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.masterclient.app.R;
import com.eoner.baselibrary.utils.ScreenUtils;
import com.tbruyelle.rxpermissions2.RxPermissions;

/**
 * 作者：sean
 * 创建时间：2017/11/1 15:22
 * 功能说明：
 */

public class IntroNewDialog extends Dialog{
    String content,title;
    ImageView iv_close;
    private TextView tv_content,tv_title,tv_contact;
    RxPermissions rxPermissions;
    public IntroNewDialog(@NonNull Context context, String title, String content) {
        super(context, R.style.MyDialog);
        this.title = title;
        this.content = content;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_intro2);
        setCanceledOnTouchOutside(true);
        tv_content = (TextView) findViewById(R.id.tv_content);
        tv_title = (TextView) findViewById(R.id.tv_title);
        tv_contact = (TextView) findViewById(R.id.tv_contact);

        tv_title.setText(title);
        tv_content.setText(content);
        iv_close = (ImageView) findViewById(R.id.iv_close);
        iv_close.setOnClickListener((v)->{
            dismiss();
        });

        tv_contact.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(contactListerner!=null){
                    contactListerner.contact();
                }
            }
        });
    }

    public interface  ContactListerner{
        public void contact();
    }

    private ContactListerner contactListerner;

    public void setContactListerner(ContactListerner contactListerner) {
        this.contactListerner = contactListerner;
    }

    @Override
    protected void onStart() {
        super.onStart();
        Window window = getWindow();
        WindowManager.LayoutParams windowparams = window.getAttributes();
        windowparams.width = ScreenUtils.getScreenWidth();
        window.setGravity(Gravity.CENTER);
        window.setBackgroundDrawableResource(android.R.color.transparent);
        window.setAttributes(windowparams);
    }
}
